/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.alien.admin.modules.deploy.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
 * @author zengzhifang
 * @website https://el-admin.vip
 * @description /
 * @date 2021-09-28
 **/
@Entity
@Data
@Table(name = "dp_server_config")
public class DpServerConfig implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "project_id", nullable = false)
    @NotNull
    @ApiModelProperty(value = "服务id")
    private Integer projectId;

    @Column(name = "env", nullable = false)
    @NotBlank
    @ApiModelProperty(value = "环境")
    private String env;

    @Column(name = "build_param")
    @ApiModelProperty(value = "构建参数的值，是一个json串")
    private String buildParam;

    @Transient
    private Boolean modifyBuildParam;

    @Column(name = "deploy_param")
    @ApiModelProperty(value = "部署参数的值")
    private String deployParam;

    @Transient
    private Boolean modifyDeployParam;

    @Column(name = "k8s_instance_id", nullable = false)
    @ApiModelProperty(value = "k8s实例id")
    private Integer k8sInstanceId;

    @Transient
    private Boolean modifyK8sInstanceId;

    @Column(name = "k8s_name_space", nullable = false)
    @ApiModelProperty(value = "k8s命名空间")
    private String k8sNameSpace;

    @Transient
    private Boolean modifyK8sNameSpace;

    @Column(name = "create_by")
    @ApiModelProperty(value = "创建人")
    private String createBy;

    @Column(name = "update_by")
    @ApiModelProperty(value = "修改人")
    private String updateBy;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建日期")
    private Timestamp createTime;

    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间")
    private Timestamp updateTime;


    public void copy(DpServerConfig source) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}